home *** CD-ROM | disk | FTP | other *** search
- Path: anvil.ugrad.cs.ubc.ca!not-for-mail
- From: c2a192@ugrad.cs.ubc.ca (Kazimir Kylheku)
- Newsgroups: comp.lang.c
- Subject: Re: F-keys/cursor keys w/curses?
- Followup-To: comp.unix.programmer
- Date: 1 Mar 1996 12:33:56 -0800
- Organization: Computer Science, University of B.C., Vancouver, B.C., Canada
- Message-ID: <4h7mvkINNstb@anvil.ugrad.cs.ubc.ca>
- References: <schellerDnHwLr.FJ9@netcom.com> <96061.093728U14873@uicvm.uic.edu>
- NNTP-Posting-Host: anvil.ugrad.cs.ubc.ca
-
- In article <96061.093728U14873@uicvm.uic.edu>,
- Bob Hyman <U14873@uicvm.uic.edu> wrote:
- >>scheller@netcom.com (Mark J. Scheller) says:
- >> ... using curses ... One thing I would like to do is take action
- >>based on the user pressing a cursor key or a function key. I'm using
- >>getch() to grab the keypresses -- the problem is that the cursor
- >>keys and the function keys return multiple key sequences for a keypress.
- >>Is there something better to use?
- >> ...
- >
- >A member of my group just got ncurses. It has support for converting
- >a sequence of input characters into a keypress. I haven't tried it
- >yet, though.
-
- So does SVR4 curses, which ncurses is strongly modelled on. Curses can detect
- things like function keys and arrow keys, and turn them into keycodes that are
- defines a symbolic constants:
-
- From the curses manual page:
-
- The following function keys could possibly be returned by getch if
- keypad has been enabled. Note that not all of these are currently
- supported due to lack of definitions in terminfo or the terminal not
- transmitting a unique code when the key is pressed.
-
- Name Value Key name
- KEY_BREAK 0401 break key (unreliable)
- KEY_DOWN 0402 The four arrow keys ...
- KEY_UP 0403
- KEY_LEFT 0404
- KEY_RIGHT 0405
- KEY_HOME 0406 Home key (upward+left arrow)
- KEY_BACKSPACE 0407 backspace (unreliable)
- KEY_F0 0410 Function keys. Space reserved
-
-
- *If* the keypad has been enabled. As I already pointed out to the poster, he
- should execute
-
- keypad(stdscr, TRUE);
-
- in his curses initialization code.
-
- Also, many curses implementations have a bug. When you use endwin() before
- ``shelling out'' to a shell prompt (needed by interactive programs with shell
- escapes, or ones which launch scripts), when you come back, the arrow keys may
- not work properly.
-
- The solution is to call keypad(stdscr, TRUE) again when you restore curses, in
- additional to the recommended procedure.
-
- (redirected to comp.unix.programmer)
- --
-
-